package com.jycrm.webservice.cust;

import javax.xml.rpc.ServiceException;

import org.springframework.remoting.jaxrpc.ServletEndpointSupport;

import com.jycrm.domain.cust.CrmCustomers;
import com.jycrm.domain.user.CrmUser;
import com.jycrm.service.cust.ICustService;
import com.jycrm.service.system.user.IUserService;

public class ModPWDServiceEndpoint extends ServletEndpointSupport implements
		IModPWDService {

	private ICustService custService;
	private IUserService useService;
	protected void onInit() throws ServiceException {
		super.onInit();
		 custService = (ICustService)getApplicationContext().getBean("custService");
		 useService = (IUserService)getApplicationContext().getBean("userService");
	}
	
	public boolean modPassWord(String legendId, Long userId, String passWD,
			Long custId, String oldCustPassWd, String newCustPassWd) {
		CrmCustomers cust = custService.getCustomerById(custId.toString());
		CrmUser user = useService.getUserById(userId);
		cust.setTaPassword(newCustPassWd);
    	try{
    		custService.updateCustomers(cust,user,"ip");
    	}catch (Exception ex){
    		ex.printStackTrace();
    		return false;
    	}
		return true;
	}

}
